package com.neuwikiback.controller;

import com.neuwikiback.pojo.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")

public class UserController {

    @PostMapping("/login")
    public Result login(String username, String password) {
        String usernameMemory = "zhangsan";
        String pwdMemory = "123456";

        if (username == null) {
            return Result.error("用户不存在");
        }

        if (username.equals(usernameMemory) && password.equals(pwdMemory)) {
            return Result.success("登录成功");
        }

        return Result.error("密码错误，登录失败");
    }

    @GetMapping("/login")
    public Result loginGet(String username, String password) {
        String usernameMemory = "zhangsan";
        String pwdMemory = "123456";

        if (username == null) {
            return Result.error("用户不存在");
        }

        if (username.equals(usernameMemory) && password.equals(pwdMemory)) {
            return Result.success("登录成功");
        }

        return Result.error("密码错误，登录失败");
    }

}
